package cp3120.dao.remote;

import cp3120.dao.VariableDAO;
import generic.net.client.Client;

/**
 *
 * @author Adam Scarr <scarr.adam@gmail.com>
 */
public class RemoteVariableDAO extends VariableDAO {
    private Client client;

    /**
     * Identifies this service
     */
    private static final String service = "RemoteVariableService";

    /**
     * creates a RemoteVariableDAO and sets the client
     * @param client the client this DAO is connected too
     */
    public RemoteVariableDAO(Client client) {
        this.client = client;
    }

    /**
     * sends a request to the server to get a varible
     * @param variable the varible to return
     * @return a varible from the server
     */
    public String getVariable(String variable) {
        return (String)client.sendRequest(service, "getVariable", variable).getResponse().getPayload();
    }

    /**
     * sends a request to the server to add a varible
     * @param variable the varible name
     * @param value the varible value
     */
    public void setVariable(String variable, String value) {
        client.sendRequest(service, "setVariable", variable, value).getResponse().getPayload();
    }
}
